import java.util.Scanner;

/**
 * @author yu
 * @date 2025年04月19日 12:48
 */
public class _09_dp_22_213rob {
    public static int rob1(int[] nums, int start , int end ){
        int x = 0, y = 0, z = 0;
        for (int i = start; i < end; i++) {
            y = z;
            z = Math.max(y, x + nums[i]);
            x = y;
        }
        return z;
    }

    public static int rob2(int[] nums){
        if (nums == null || nums.length == 0)
            return 0;
        int len = nums.length;
        if (len == 1)
            return nums[0];
        return Math.max(rob1(nums, 0, len - 1), rob1(nums, 1, len));
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] nums = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = scanner.nextInt();
        }
        System.out.println(rob2(nums));
        scanner.close();
    }
}
